package cn.tedu.micro.demo.order.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 拦截全局某些客户端发送的请求 添加cookie
 */
@Configuration
public class GlobalFeignCookieConfig {
    //初始化一个拦截器对象
    @Bean
    public RequestInterceptor requestInterceptor(){
        return new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                //所有的restTemplate发送的请求 都组织添加一个cookie
                requestTemplate.header("Cookie","name=wangcuihua");
            }
        };
    }
}
